home *** CD-ROM | disk | FTP | other *** search
- /************************************************************
- *
- * Created: Friday, December 4, 1992 7:32:00 AM
- * NeoFailure.h
- * Definition of failure contructs
- *
- * Copyright © Neologic Systems 1992-1993. All Rights Reserved.
- * All rights reserved
- *
- ***********************************************************/
- #pragma once
- #ifndef __NEOFAILURE__
- #define __NEOFAILURE__ 1 /* Include this file only once */
-
- #include "NeoTypes.h"
-
- #define qNeoFailures 1
-
- #include <setjmp.h>
-
- typedef struct FailInfo
- {
- char fPropagate;
- struct FailInfo *next;
- jmp_buf regs;
- } FailInfo;
-
- // Macros for handling failures
- extern short gLastError; /* last error code that caused a failure */
- extern long gLastMessage; /* last message associated with a failure */
- void ArmHandler(FailInfo *aFailInfo);
- void FailMemError(void);
- void FailNIL(const void *aPtr);
- void FailOSErr(const OSErr aError);
- void Failure(const OSErr aError, const long aMsg);
- void RetryException(FailInfo *aFailInfo);
- void Success(void);
- void NoHandler(void);
- void SetFailInfo(const short aError, const long aMessage);
- long SpecifyMsg(const short aListID, const short aIndex);
-
- #define NEOTRY \
- { FailInfo __fi; \
- ArmHandler(&__fi); \
- if (!setjmp(__fi.regs)) {
-
- #define NEOCATCH \
- Success(); } \
- else {
-
- #define NEOENDTRY \
- if (__fi.fPropagate) \
- Failure(gLastError, gLastMessage); \
- } }
-
- #define NEORETRY \
- RetryException(&__fi)
-
- #define NO_PROPAGATE \
- __fi.fPropagate = 0
-
- #define NEOTRYTO \
- { int __result; \
- FailInfo __fi; \
- ArmHandler(&__fi); \
- __result = setjmp(__fi.regs); \
- if (!__result) {
-
- #define NEOCLEANUP \
- Success(); }
-
- #define NEOENDTRYTO \
- if (__result && __fi.fPropagate) \
- Failure(gLastError, gLastMessage); \
- }
-
- #define TRY NEOTRY
- #define CATCH NEOCATCH
- #define ENDTRY NEOENDTRY
- #define RETRY NEORETRY
- #define TRYTO NEOTRYTO
- #define CLEANUP NEOCLEANUP
- #define ENDTRYTO NEOENDTRYTO
-
-
- #define NeoPropagateFailure(x) __fi.fPropagate = (x)
- #define NeoFailErr() gLastError
- #endif
-